<template>
  <el-container style="min-height: 100vh">
    <el-aside
      :width="sideWidth + 'px'"
      style="
        background-color: rgb(74, 51, 167);
        box-shadow: 2px 0 6px rgb(0 21 41 / 35%);
      "
    >
      <el-menu
        :default-openeds="false"
        style="min-height: 100%; overflow-x: hidden"
        background-color="rgb(28, 52, 89)"
        text-color="#fff"
        active-text-color="#ffd04b"
        :collapse-transition="false"
        :collapse="isCollapse"
        unique-opened
        router
        :default-active="activePath"
      >
        <div style="height: 50px; line-height: 30px; text-align: center">
          <img
            src="../assets/1.jpg"
            alt=""
            style="
              width: 50px;
              position: relative;
              top: 15px;
              margin-right: 10px;
            "
          />
          <b style="color: white" v-show="logoTextShow">楚衣云盘</b>
        </div>

        <el-menu-item :index="'/welcome'">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <el-menu-item @click="saveNavstatu('/users')" :index="'/users'">
          <i class="el-icon-menu"></i>
          <span slot="title">所有文件</span>
        </el-menu-item>

        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-s-order"></i>
            <span>文件分类</span>
          </template>

          <el-menu-item @click="saveNavstatu('/pictures')" :index="'/pictures'">
            <i class="el-icon-picture-outline-round"></i>
            <span slot="title">成品图片</span>
          </el-menu-item>

          <el-menu-item @click="saveNavstatu('/videos')" :index="'/videos'">
            <i class="el-icon-video-camera"></i>
            <span slot="title">走秀视频</span>
          </el-menu-item>

          <el-menu-item @click="saveNavstatu('/musics')" :index="'/musics'">
            <i class="el-icon-headset"></i>
            <span slot="title">背景音乐</span>
          </el-menu-item>

          <el-menu-item
            @click="saveNavstatu('/documents')"
            :index="'/documents'"
          >
            <i class="el-icon-document-remove"></i>
            <span slot="title">服装资料</span>
          </el-menu-item>
        </el-submenu>

        <el-menu-item @click="saveNavstatu('/stores')" :index="'/stores'">
          <i class="el-icon-star-on"></i>
          <span slot="title">我的收藏</span>
        </el-menu-item>

        <el-menu-item @click="saveNavstatu('/rubbishs')" :index="'/rubbishs'">
          <i class="el-icon-delete-solid"></i>
          <span slot="title">回收站</span>
        </el-menu-item>

        <el-submenu>
          <template slot="title">
            <i class="el-icon-user-solid"></i>
            <span>个人中心</span>
          </template>

          <el-menu-item
            @click="saveNavstatu('/showinfos')"
            :index="'/showinfos'"
          >
            <i class="el-icon-info"></i>
            <span slot="title">基本信息</span>
          </el-menu-item>

          <el-menu-item
            @click="saveNavstatu('/infoeditors')"
            :index="'/infoeditors'"
          >
            <i class="el-icon-edit"></i>
            <span slot="title">信息修改</span>
          </el-menu-item>

          <el-menu-item
            @click="saveNavstatu('/countcontrols')"
            :index="'/countcontrols'"
          >
            <i class="el-icon-coordinate"></i>
            <span slot="title">密码修改</span>
          </el-menu-item>
          <!-- <el-menu-item @click="saveNavstatu('/userpics')" :index="'/userpics'">
            <i class="el-icon-document-remove"></i>
            <span slot="title">头像修改</span>
          </el-menu-item> -->
        </el-submenu>

        <el-menu-item @click="saveNavstatu('/home')" :index="'/home'">
          <i class="el-icon-arrow-right"></i>
          <span slot="title">回到首页</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header
        style="
          font-size: 12px;
          border-bottom: 1px solid #ccc;
          line-height: 60px;
          display: flex;
        "
      >
        <div style="flex: 1; font-size: 20px">
          <span
            :class="collapseBtnClass"
            style="cursor: pointer"
            @click="collapse"
          ></span>
        </div>
        <el-dropdown style="width: 70px; cursor: pointer">
          <el-button type="info" @click="loginOut">退出</el-button>
          <el-dropdown-menu></el-dropdown-menu>
        </el-dropdown>
      </el-header>

      <!-- 主体 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      activePath: "",

      collapseBtnClass: "el-icon-s-fold",
      isCollapse: false,
      sideWidth: 180,
      logoTextShow: true,
    };
  },
  methods: {
    loginOut() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    // saveNavstatu(activePath) {
    //   window.sessionStorage.setItem("activePath", activePath);
    //   this.activePath = activePath;
    //   console.log("---------");
    //   console.log(this.activePath);
    //   this.$router.push(this.activePath);
    // },

    collapse() {
      // 点击收缩按钮触发
      this.isCollapse = !this.isCollapse;
      if (this.isCollapse) {
        // 收缩
        this.sideWidth = 64;
        this.collapseBtnClass = "el-icon-s-unfold";
        this.logoTextShow = false;
      } else {
        // 展开
        this.sideWidth = 180;
        this.collapseBtnClass = "el-icon-s-fold";
        this.logoTextShow = true;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
}
.el-header {
  background-color: #5c68d2;
  display: flex;
  justify-content: space-between;
  padding-left: 5;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 15px;
    }
  }
}
.el-aside {
  // background-color: #97c951;
  background: url("../assets/5.jpg");
  background-size: cover;
  .el-menu {
    border-right: none;
    opacity: 0.8;
  }
}

.el-main {
  background-color: #508ca9e9;
  background: url("../assets/9.jpg");
  background-size: cover;
}

.iconfont {
  margin-right: 10px;
}

.toggle-button {
  background-color: #d25925c6;
  // background: url("../assets/5.jpg");
  font-size: 10px;
  line-height: 24px;
  color: #af3d3db7;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
